package com.lz.b;

import java.util.Scanner;

/**
 * @ClassName Demo13
 * @Description 求数字的绝对值
 * @Author 2214361854
 * @Date 2022/5/27 9:11
 * @Version 1.0
 */
public class Demo13 {
    /*
    接收用户输入的数字，输出绝对值结果
     */
    public static void main(String[] args) {
        System.out.println("输入数字：");
        double input = new Scanner(System.in).nextDouble();
        System.out.println("绝对值：" + getAbsNum(input));
    }

    private static double getAbsNum(double input) {
        if (input >= 0) {
            return input;
        } else {
            return -input;
        }
    }
}
